<extend name="layout/edit" />

<block name="HEADER">
	
</block>

<block name="CONTENT">
	<div style="height: calc(100% - 42px);">
		<control:grid id="selectGoodsSpecsGrid" />
	</div>
    <div class="xw-form">
		<div class="xw-btnRow" style="text-align: right;">
			<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="page.save()" >
				保存
			</button> 
			<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="$.close()">
				关闭
			</button>
		</div>
	</div>
</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function(ns) {
			
			ns.selectedIds = [];
			
			ns.init = function(){
				var goods_id = $.getRequest('goods_id');
				selectGoodsSpecsGrid.queryFront(function(res){ 
					res.push({"field":"goods_id","opera":"=","value": goods_id });
					return res; 
				});
			}
			
			//搜索事件
			ns.save = function() {
				var ids = selectGoodsSpecsGrid.getSelectedColumnValue('id');
				var datas = selectGoodsSpecsGrid.getSelectedRows();
				if(!ids){
					$.toast(0,"请先选择规格！");
					return false;
				}
				if( parent.page && parent.page.selectSpecsCallback){
					if(parent.page.selectSpecsCallback(ids,datas) !== false){
						$.close();
					}
				}else{
					$.close();
				}
			}

			return ns;
		}({}));

		$(function() { page.init(); });
	</script>
</block>